<?php

abstract class commDbResourceAbstract
{
    protected $db;
    protected $type;

    function __construct($db, $type)
    {
        $this->db = $db;
        $this->type = $type;
    }

    public static function resource($db, $type = 'pdo')
    {
        if (empty($db)) {
            throw new exceptionDb('해당 DB 에 대한 ID 값이 없습니다.');
        }
    }

    abstract function getDsn();

    protected function setDsnForMDB($aDsn)
    {
        $_aDsn = array(
            'phptype' =>$aDsn['type'],
            'username' => $aDsn['user'],
            'password' => $aDsn['pwd'],
            'hostspec' => $aDsn['host'],
            'database' => $aDsn['db'],
            'port' => $aDsn['port']
        );

        return $_aDsn;
    }

    protected function setDnsForPDO()
    {
        $_aDsn = array(
            'dsn' => $aDsn['type'].':dbname='.$aDsn['db'].';host='.$aDsn['host'],
            'user' => $aDsn['user'],
            'passwd' => $aDsn['pwd']
        );

        return $_aDsn;
    }
}